package servlet;

import bao.CustomerDao;
import model.Customer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class CusRegiset_Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        String name = req.getParameter("name");
        String password = req.getParameter("password");
        String sex = req.getParameter("sex");
        String email = req.getParameter("email");
        System.out.println(sex);
        Customer customer = new Customer(name,password,sex,email);
        CustomerDao customerDao = new CustomerDao();
        boolean result = customerDao.InsertCustomer(customer);
        System.out.println(result);
        if(result){
            resp.sendRedirect("webpage/DetailPage.jsp");
        }
    }
}
